import {Component, Input, OnInit} from '@angular/core';
import {HttpService} from '../http.service';
import {ActivatedRoute, Router} from '@angular/router';
import { Student} from '../student';
import {Location} from '@angular/common';

@Component({
  selector: 'app-course-detail',
  templateUrl: './student-detail.component.html',
  styleUrls: ['./student-detail.component.css']
})
export class StudentDetailComponent implements OnInit {
  StudentDetail: Student = {
    stuid : null,
    name: '',
    birthday: '' ,
    class : '',
    major : '' ,
    native_place : '' ,
    sex : '' ,
    time_of_enrollment : '' ,
  };
  constructor( private httpService: HttpService,
               private route: ActivatedRoute,
               private location: Location, ) { }

  stuid: any = String(this.route.snapshot.paramMap.get('stuid'));
  loading = true;
  size = 'default';
  getStudentDetail() {
    // @ts-ignore
    this.httpService.getStudentDetail(this.stuid).subscribe(
      res => this.StudentDetail = {
                    stuid : res.data.stuid,
                    name: res.data.name,
                    birthday : res.data.birthday,
                    class : res.data.class,
                    major : res.data.major,
                    native_place : res.data.native_place,
                    sex : res.data.sex,
                    time_of_enrollment : res.data.time_of_enrollment
      });
    console.log('获取信息成功');
    this.loading = false;

  }

  ngOnInit(): void {
    this.getStudentDetail();
  }
}
